﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EIS_desktop
{
    public partial class EmergencyContactInformation : Form
    {
        
        public EmergencyContactInformation()
        {
            InitializeComponent();
        }

        private void textBoxName_Validating(object sender, CancelEventArgs e)
        {
            if (textBoxName.Text == "")
            {
                errorProvider1.SetError(textBoxName, "Enter Name");
            }
            else
            {
                errorProvider1.SetError(textBoxName, "");
            }

        }

        private void textBoxAddress_Validating(object sender, CancelEventArgs e)
        {
            if (textBoxAddress.Text == "")
            {
                errorProvider1.SetError(textBoxAddress, "Enter Complete Address");
            }
            else
            {
                errorProvider1.SetError(textBoxAddress, "");
            }


        }

        private void HomePhone_Validating(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rphn = new System.Text.RegularExpressions.Regex(@"^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$");
            if (!rphn.IsMatch(HomePhone.Text))
            {
                errorProvider1.SetError(HomePhone, "enter phone number in US format,e.g (777)777-7777 or (777) 777-7777");
            }
            else
            {
                errorProvider1.SetError(HomePhone, "");
            }
            

        }

        private void CellPhone_Validating(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rphn = new System.Text.RegularExpressions.Regex(@"^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$");
            if (!rphn.IsMatch(CellPhone.Text))
            {
                errorProvider1.SetError(CellPhone, "enter cell number in US format,e.g (777)777-7777 or (777) 777-7777");
            }
            else
            {
                errorProvider1.SetError(CellPhone, "");
            }
            

        }

        private void textBoxEMAddr_Validating(object sender, CancelEventArgs e)
        {

            System.Text.RegularExpressions.Regex rEMail = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z][\w\._]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\._]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
            if (!rEMail.IsMatch(textBoxEMAddr.Text))
            {
                errorProvider1.SetError(textBoxEMAddr, "Enter Correct Format,freerhyme@abc.com");
            }
            else
            {
                errorProvider1.SetError(textBoxEMAddr, "");
            }
           

        }

        private void tRelationShip_Validating(object sender, CancelEventArgs e)
        {
            if (tRelationShip.Text == "")
            {
                errorProvider1.SetError(tRelationShip, "Enter RelationShip");
            }
            else
            {
                errorProvider1.SetError(tRelationShip, "");
            }

        }

        private void tPhNoW_Validating(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rphn = new System.Text.RegularExpressions.Regex(@"^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$");
            if (!rphn.IsMatch(tPhNoW.Text))
            {
                errorProvider1.SetError(tPhNoW, "enter phone number in US format,e.g (777)777-7777 or (777) 777-7777");
            }
            else
            {
                errorProvider1.SetError(tPhNoW, "");
            }
            

        }

        private void tPhNoH_Validating(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rphn = new System.Text.RegularExpressions.Regex(@"^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$");
            if (!rphn.IsMatch(tPhNoH.Text))
            {
                errorProvider1.SetError(tPhNoH, "enter phone number in US format,e.g (777)777-7777 or (777) 777-7777");
            }
            else
            {
                errorProvider1.SetError(tPhNoH, "");
            }
            

        }

        private void tPhNoCell_Validating(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rphn = new System.Text.RegularExpressions.Regex(@"^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$");
            if (!rphn.IsMatch(tPhNoCell.Text))
            {
                errorProvider1.SetError(tPhNoCell, "enter  Cell number in US format,e.g (777)777-7777 or (777) 777-7777");
            }
            else
            {
                errorProvider1.SetError(tPhNoCell, "");
            }
            

        }

        private void tARelationShip_Validating(object sender, CancelEventArgs e)
        {
            if (tARelationShip.Text == "")
            {
                errorProvider1.SetError(tARelationShip, "Enter RelationShip");
            }
            else
            {
                errorProvider1.SetError(tARelationShip, "");
            }


        }

        private void tAPhNoW_Validating(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rphn = new System.Text.RegularExpressions.Regex(@"^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$");
            if (!rphn.IsMatch(tAPhNoW.Text))
            {
                errorProvider1.SetError(tAPhNoW, "enter phone number in US format,e.g (777)777-7777 or (777) 777-7777");
            }
            else
            {
                errorProvider1.SetError(tAPhNoW, "");
            }
            

        }

        private void tAPhNoH_Validating(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rphn = new System.Text.RegularExpressions.Regex(@"^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$");
            if (!rphn.IsMatch(tAPhNoH.Text))
            {
                errorProvider1.SetError(tAPhNoH, "enter phone number in US format,e.g (777)777-7777 or (777) 777-7777");
            }
            else
            {
                errorProvider1.SetError(tAPhNoH, "");
            }
            

        }

        private void tAPhNoC_Validating(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rphn = new System.Text.RegularExpressions.Regex(@"^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$");
            if (!rphn.IsMatch(tAPhNoC.Text))
            {
                errorProvider1.SetError(tAPhNoC, "enter phone number in US format,e.g (777)777-7777 or (777) 777-7777");
            }
            else
            {
                errorProvider1.SetError(tAPhNoC, "");
            }
            

        }

        private void tcity_Validating(object sender, CancelEventArgs e)
        {

            if (tcity.Text == "")
            {
                errorProvider1.SetError(tcity, "Enter City");
            }
            else
            {
                errorProvider1.SetError(tcity, "");
            }




        }

        private void tstate_Validating(object sender, CancelEventArgs e)
        {
            if (tstate.Text == "")
            {
                errorProvider1.SetError(tstate, "Enter State");
            }
            else
            {
                errorProvider1.SetError(tstate, "");
            }

        }

        private void tzip_Validating(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rzip=new System.Text.RegularExpressions.Regex(@"(^\d{5}$)|(^\d{5}-\d{4}$)");
            if (!rzip.IsMatch(tzip.Text))
            {
                errorProvider1.SetError(tzip, "ZipCode Should Have five Digit");
            }
            else
            {
                errorProvider1.SetError(tzip, "");
            }



        }

       
       
        
      
        
    }
}
